<html>   
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">   
<title>tomcat</title>   
<link href="favicon.ico" rel="icon" type="image/x-icon" />
        <link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <link href="tomcat.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function copyUrl()
{
var Url=document.getElementById("biao1");
Url.select(); 
document.execCommand("Copy"); 
}
function copyUr2()
{
var Ur2=document.getElementById("biao2");
Ur2.select(); 
document.execCommand("Copy"); 
}
function copyUr3()
{
var Ur3=document.getElementById("biao3");
Ur3.select(); 
document.execCommand("Copy"); 
}
function copyUr4()
{
var Ur4=document.getElementById("biao4");
Ur4.select(); 
document.execCommand("Copy"); 
}
function copyUr5()
{
var Ur5=document.getElementById("biao5");
Ur5.select(); 
document.execCommand("Copy"); 
}
function copyUr6()
{
var Ur6=document.getElementById("biao6");
Ur6.select(); 
document.execCommand("Copy"); 
}
function copyUr7()
{
var Ur7=document.getElementById("biao7");
Ur7.select(); 
document.execCommand("Copy"); 
}
</script>
<script type="text/javascript">
function Show_Hidden(obj)
{
 if(obj.style.display=="block")
 {
  obj.style.display='none';
 }
 else
 {
  obj.style.display='block';
 }
}
window.onload=function()
{
 var olink=document.getElementById("link");
 var odiv=document.getElementById("thediv");
 olink.onclick=function()
 {
  Show_Hidden(odiv);
  return false;
 }
}
</script>

<!-- conn.java -->
<textarea id="biao1" style="width: 0; height: 0">
	package com.test.conn;

	import java.sql.*;

	public class Conn {
		public static final String DBDRIVER="org.gjt.mm.mysql.Driver";
		public static final String DBURL="jdbc:mysql://localhost:3306/test?useSSL=false";
		public static final String DBUSER="root";
		public static final String DBPASS="123456";
		
		Connection conn = null;
		public Connection getConn() {
			try {
				Class.forName(DBDRIVER);
				conn = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
			}catch(Exception e) {
				e.printStackTrace();
			}
			return conn;
		}
		
		public void closeConn() {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
</textarea>

<textarea id="biao2" style="width: 0; height: 0">
	public ResultSet Login(User user){
		ResultSet rs = null;
		try{
			Conn conn = new Conn();
			Connection dbc = conn.getConn();
			String sql_login = "select * from user2 where username=? and password=? and type=?";
			PreparedStatement pst = dbc.prepareStatement(sql_login);
			pst.setString(1,user.getUsername());
			pst.setString(2,user.getPassword());
			pst.setString(3, user.getType());
			rs = pst.executeQuery();
		}catch(Exception e){
			e.printStackTrace();
		}
		return rs;
	}
</textarea>

<textarea id="biao3" style="width: 0; height: 0">
	public List&lt;User&gt; SelectUser(){
		List&lt;User&gt; userlist = new ArrayList&lt;User&gt;();
		ResultSet rs = null; 
		try{
			Conn conn = new Conn();
			Connection dbc = conn.getConn();
			String sql_select = "select * from user2";
			PreparedStatement pst = dbc.prepareStatement(sql_select);
			rs = pst.executeQuery();
			while(rs.next()){
				User user = new User();
				user.setId(Integer.parseInt(rs.getString("id")));
				user.setUsername(rs.getString("username"));
				user.setPassword(rs.getString("password"));
				user.setType(rs.getString("type"));
				userlist.add(user);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return userlist;
	}
</textarea>

<textarea id="biao4" style="width: 0; height: 0">
	public void Delete(int id){
		try{
			Conn conn = new Conn();
			Connection dbc = conn.getConn();
			String sql_delete = "DELETE FROM user2 WHERE id = ? ";
			PreparedStatement pst= dbc.prepareStatement(sql_delete);
			pst.setString(1,id+"");
			pst.executeUpdate();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
</textarea>

<textarea id="biao5" style="width: 0; height: 0">
	public List&lt;User&gt; SelectbyID(int id){
		ResultSet rs = null;
		List&lt;User&gt; rslist = new ArrayList();
		try{
			Conn conn = new Conn();
			Connection dbc = conn.getConn();
			String sql_select = "select * from user2 where id=?";
			PreparedStatement pst = dbc.prepareStatement(sql_select);
			pst.setString(1, id+"");
			rs = pst.executeQuery();
			while(rs.next()){
				User user = new User();
				user.setUsername(rs.getString("username"));
				user.setPassword(rs.getString("password"));
				user.setType(rs.getString("type"));
				rslist.add(user);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return rslist;
	}
</textarea>

<textarea id="biao6" style="width: 0; height: 0">
	public void Update(User user){
		try{
			Conn conn = new Conn();
			Connection dbc = conn.getConn();
			String sql_update = "UPDATE user2 SET username = ?,password=? WHERE id =? ";
			PreparedStatement pst = dbc.prepareStatement(sql_update);
			pst.setString(1,user.getUsername());
			pst.setString(2, user.getPassword());
			pst.setString(3,user.getId()+"");
			System.out.println(pst);
			pst.executeUpdate();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
</textarea>
<textarea id="biao7" style="width: 0; height: 0">
    &lt;div id="G_headleft"&gt;
    <%
        Object user = session.getAttribute("user");
        if(session.getAttribute("user") == null){
            out.println("您还未登录，&lt;a href='./login.jsp'>登录&lt;/a&gt;后查看更多内容");
        }
        else{
            out.println("欢迎"+user+"点击&lt;a href='removeSe.jsp'&gt;此处&lt;/a&gt;注销");
        }
    %>
&lt;/div&gt;

session.setAttribute("user",username);
session.setMaxInactiveInterval(60);

window.location.href="./login.jsp";

request.setCharacterEncoding("utf-8");

if(remember!=null){
    Cookie c1 = new Cookie("username",username);
    Cookie c2 = new Cookie("password",password);
    c1.setMaxAge(150);
    c2.setMaxAge(150);
    response.addCookie(c1);
    response.addCookie(c2);
}

<%
//判断是否在cookie中保存了密码
    String username = "";
    String password = "";
    Cookie[] cookies = request.getCookies();
    if(cookies != null){
        for(int i = 0 ;i < cookies.length ; i++){
            if("username".equals(cookies[i].getName())){
                username = cookies[i].getValue();
            }
            else if("password".equals(cookies[i].getName())){
                password = cookies[i].getValue();
            }
        }
    }
    else{
        username = "";
        password = "";
    }
%>

&lt;script&gt;
    function checklogin(){
        if((loginform.username.value!="")){
            if((loginform.pwd.value!="")){
                return true;
            }
            else{
                alert("密码不能为空！");
                return false;
            }
        }
        else{
            alert("用户名不能为空！");
            return false;
        }
    }
&lt;/script&gt;
</textarea>
<div id="wrapper">
            <div id="navigation" class="curved container">
                <span id="nav-home"><a href="http://tomcat.apache.org/">Home</a></span>
                <span id="nav-hosts"><a href="/docs/">Documentation</a></span>
                <span id="nav-config"><a href="/docs/config/">Configuration</a></span>
                <span id="nav-examples"><a href="/examples/">Examples</a></span>
                <span id="nav-wiki"><a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a></span>
                <span id="nav-lists"><a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></span>
                <span id="nav-help"><a href="http://tomcat.apache.org/findhelp.html">Find Help</a></span>
                <br class="separator" />
            </div>
            <div id="asf-box">
                <h1>Apache Tomcat/8.0.50</h1>
            </div>
            <div id="upper" class="curved container">
                <div id="congrats" class="curved container">
                    <h2>If you're seeing this, you've successfully installed Tomcat. Congratulations!</h2>
                </div>
                <div id="notice">
                    <img src="tomcat.png" alt="[tomcat logo]" />
                    <div id="tasks">
                        <h3>Recommended Reading:</h3>
                        <h4><a href="/docs/security-howto.html">Security Considerations HOW-TO</a></h4>
                        <h4><a href="/docs/manager-howto.html">Manager Application HOW-TO</a></h4>
                        <h4><a href="/docs/cluster-howto.html">Clustering/Session Replication HOW-TO</a></h4>
                    </div>
                </div>
                <div id="actions">
                    <div class="button">
                        <a class="container shadow" href="/manager/status"><span>Server Status</span></a>
                    </div>
                    <div class="button">
                        <a class="container shadow" href="/manager/html"><span>Manager App</span></a>
                    </div>
                    <div class="button">
                        <a class="container shadow" href="/host-manager/html"><span>Host Manager</span></a>
                    </div>
                </div>
                <!--
                <br class="separator" />
                -->
                <br class="separator" />
            </div>
            <div id="middle" class="curved container">
                <h3>Developer Quick Start</h3>
                <div class="col25">
                    <div class="container">
                        <p><a href="/docs/setup.html">Tomcat Setup</a></p>
                        <p><a href="/docs/appdev/">First Web Application</a></p>
                    </div>
                </div>
                <div class="col25">
                    <div class="container">
                        <p><a href="/docs/realm-howto.html">Realms &amp; AAA</a></p>
                        <p><a href="/docs/jndi-datasource-examples-howto.html">JDBC DataSources</a></p>
                    </div>
                </div>
                <div class="col25">
                    <div class="container">
                        <p><a href="/examples/">Examples</a></p>
                    </div>
                </div>
                <div class="col25">
                    <div class="container">
                        <p><a href="http://wiki.apache.org/tomcat/Specifications">Servlet Specifications</a></p>
                        <p><a href="http://wiki.apache.org/tomcat/TomcatVersions">Tomcat Versions</a></p>
                    </div>
                </div>
                <br class="separator" />
            </div>
            <div id="lower">
                <div id="low-manage" class="">
                    <div class="curved container">
                        <h3>Managing Tomcat</h3>
                        <p>For security, access to the <a href="/manager/html">manager webapp</a> is restricted.
                        Users are defined in:</p>
                        <pre>$CATALINA_HOME/conf/tomcat-users.xml</pre>
                        <p>In Tomcat 8.0 access to the manager application is split between
                           different users. &nbsp; <a href="/docs/manager-howto.html">Read more...</a></p>
                        <br />
                        <h4><a href="/docs/RELEASE-NOTES.txt">Release Notes</a></h4>
                        <h4><a href="/docs/changelog.html">Changelog</a></h4>
                        <h4><a href="http://tomcat.apache.org/migration.html">Migration Guide</a></h4>
                        <h4><a href="http://tomcat.apache.org/security.html">Security Notices</a></h4>
                    </div>
                </div>
                <div id="low-docs" class="">
                    <div class="curved container">
                        <h3>Documentation</h3>
                        <h4><a href="/docs/">Tomcat 8.0 Documentation</a></h4>
                        <h4><a href="/docs/config/">Tomcat 8.0 Configuration</a></h4>
                        <h4><a href="http://wiki.apache.org/tomcat/FrontPage">Tomcat Wiki</a></h4>
                        <p>Find additional important configuration information in:</p>
                        <pre>$CATALINA_HOME/RUNNING.txt</pre>
                        <p>Developers may be interested in:</p>
                        <ul>
                            <li><a href="http://tomcat.apache.org/bugreport.html">Tomcat 8.0 Bug Database</a></li>
                            <li><a href="/docs/api/index.html">Tomcat 8.0 JavaDocs</a></li>
                            <li><a href="http://svn.apache.org/repos/asf/tomcat/tc8.0.x/">Tomcat 8.0 SVN Repository</a></li>
                        </ul>
                    </div>
                </div>
                <div id="low-help" class="">
                    <div class="curved container">
                        <h3>Getting Help</h3>
                        <h4><a href="http://tomcat.apache.org/faq/">FAQ</a> and <a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></h4>
                        <p>The following mailing lists are available:</p>
                        <ul>
                            <li id="list-announce"><strong><a href="http://tomcat.apache.org/lists.html#tomcat-announce">tomcat-announce</a><br />
                                Important announcements, releases, security vulnerability notifications. (Low volume).</strong>
                            </li>
                            <li><a href="http://tomcat.apache.org/lists.html#tomcat-users">tomcat-users</a><br />
                                User support and discussion
                            </li>
                            <li><a href="http://tomcat.apache.org/lists.html#taglibs-user">taglibs-user</a><br />
                                User support and discussion for <a href="http://tomcat.apache.org/taglibs/">Apache Taglibs</a>
                            </li>
                            <li><a href="http://tomcat.apache.org/lists.html#tomcat-dev">tomcat-dev</a><br />
                                Development mailing list, including commit messages
                            </li>
                        </ul>
                    </div>
                </div>
                <br class="separator" />
            </div>
            <div id="footer" class="curved container">
                <div class="col20">
                    <div class="container">
                        <h4>Other Downloads</h4>
                        <ul>
                            <li><a href="http://tomcat.apache.org/download-connectors.cgi">Tomcat Connectors</a></li>
                            <li><a href="http://tomcat.apache.org/download-native.cgi">Tomcat Native</a></li>
                            <li><a href="http://tomcat.apache.org/taglibs/">Taglibs</a></li>
                            <li><a href="/docs/deployer-howto.html">Deployer</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col20">
                    <div class="container">
                        <h4>Other Documentation</h4>
                        <ul>
                            <li><a href="http://tomcat.apache.org/connectors-doc/">Tomcat Connectors</a></li>
                            <li><a href="http://tomcat.apache.org/connectors-doc/">mod_jk Documentation</a></li>
                            <li><a href="http://tomcat.apache.org/native-doc/">Tomcat Native</a></li>
                            <li><a href="/docs/deployer-howto.html">Deployer</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col20">
                    <div class="container">
                        <h4>Get Involved</h4>
                        <ul>
                            <li><a href="http://tomcat.apache.org/getinvolved.html">Overview</a></li>
                            <li><a href="http://tomcat.apache.org/svn.html">SVN Repositories</a></li>
                            <li><a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></li>
                            <li><a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col20">
                    <div class="container">
                        <h4>Miscellaneous</h4>
                        <ul>
                            <li><a href="http://tomcat.apache.org/contact.html">Contact</a></li>
                            <li><a href="http://tomcat.apache.org/legal.html">Legal</a></li>
                            <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
                            <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col20">
                    <div class="container">
                        <h4>Apache Software Foundation</h4>
                        <ul>
                            <li><a href="http://tomcat.apache.org/whoweare.html">Who We Are</a></li>
                            <li><a href="http://tomcat.apache.org/heritage.html">Heritage</a></li>
                            <li><a href="http://www.apache.org">Apache Home</a></li>
                            <li><a href="http://tomcat.apache.org/resources.html">Resources</a></li>
                        </ul>
                    </div>
                </div>
                <br class="separator" />
            </div>
        </div>
<a href="#" id="link" class="copyright">Copyright ©1999-2018 Apache Software Foundation. All Rights Reserved</a>
<div id="thediv" style="display:none">
    <input type="button" onClick="copyUrl()" value="conn" />  
    <input type="button" onClick="copyUr2()" value="login" />  
    <input type="button" onClick="copyUr3()" value="select" />  
    <input type="button" onClick="copyUr4()" value="delete" />  
    <input type="button" onClick="copyUr5()" value="selectbyid" />  
    <input type="button" onClick="copyUr6()" value="updata" /> 
    <input type="button" onClick="copyUr7()" value="cook/see" />  
</div>
</body> 
</html>